package com.blb.mvc.controller;

import com.blb.mvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;

/**
 * 自定义控制器
 */
@Controller
public class HelloController {

    /**
     * 访问hello页面的请求方法
     * toHello --> viewResolver --> hello --> /WEB-INF/pages/hello.jsp
     * @return
     */
    @RequestMapping("/toHello")
    //@SessionAttribute("user") 读取session中的属性
    public String hello(@SessionAttribute("user") User user ){
        System.out.println("执行了toHello" + user);
        return "hello";
    }
}
